//封装网络请求
const baseUrl = 'http://47.91.230.137:8086'
const request = (options = {}) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url:baseUrl + options.url || '',
			method: options.type || 'GET',
			data: options.data || {},
			header: {
				Authorization: uni.getStorageSync('token') //这里打错
			}|| {},
		}).then((response) => {
			resolve(response);
		}).catch(error => {
			let [err,res]=error;
			rejects(err)
		})
	});
}
 const get = (url, data, options = {}) => { //这里也打错
	 options.type ='get';
	 options.data=data; //这里也大错
	 options.url =url;
	 return request(options)
 }
 const post = (url,data,options = {}) => {
	 options.type ='post';
	 options.data=data;
	 options.url =url;
	 return request(options)
 }
 const put = (url, data, options = {}) => {
	 options.type ='put';
	 options.data=data;
	 options.url =url;
	 return request(options)
 }
const deletes = (url, data, options = {}) => {
	options.type ='deletes';
	options.data=data;
	options.url =url;
	return request(options)
}
export default {
	request,
	get,
	post,
	put,
	baseUrl,
	deletes
}